package org.sfs.storemypassword.install;

import java.security.NoSuchAlgorithmException;
import java.util.Date;

import org.romaframework.module.users.UsersHelper;
import org.romaframework.module.users.domain.BaseAccount;
import org.romaframework.module.users.domain.BaseProfile;
import org.romaframework.module.users.install.UsersApplicationInstaller;

public class CustomApplicationInstaller extends UsersApplicationInstaller {

	private static final String	HOME_PAGE_REGISTER	= "HomePageRegister";
	public static final String	ACCOUNT_REGISTER		= "register";
	protected BaseProfile				pRegister;

	@Override
	protected void createProfiles() {
		super.createProfiles();
		pRegister = new BaseProfile(realm);
		pRegister.setName(ACCOUNT_REGISTER);
		pRegister.setHomePage(HOME_PAGE_REGISTER);
		pRegister.setMode(BaseProfile.MODE_ALLOW_ALL_BUT);
		UsersHelper.getInstance().setProfile(pRegister);
	}

	@Override
	protected void createAccounts() throws NoSuchAlgorithmException {
		super.createAccounts();
		BaseAccount aRegister = new BaseAccount(realm);
		aRegister.setName(ACCOUNT_REGISTER);
		aRegister.setPassword(ACCOUNT_REGISTER);
		aRegister.setSignedOn(new Date());
		aRegister.setStatus(defStatus);
		aRegister.setLastModified(aRegister.getSignedOn());
		aRegister.setProfile(pRegister);
		UsersHelper.getInstance().setAccount(aRegister);
	}

}
